/*-------------------------------------------------------------------------
 * CLR版本:     4.0.30319.42000
 * 创建人:      song
 * 创建时间：   2024/4/9 17:56:20
 * 功 能：      Float 绘制器
 *-------------------------------------------------------------------------*/

#if UNITY_EDITOR
namespace SCore.Editor.SShaderDraw
{
    using System.Collections.Generic;
    using UnityEditor;
    using UnityEngine;

    public class SFloatProp : SPropSuperBase<float>
    {
        public SFloatProp(string name, GUIContent label, MaterialEditor materialEditor,
            Dictionary<string, MaterialProperty> props) : base(name, label, materialEditor, props, 1f)
        {
        }

        public SFloatProp(string name, GUIContent label, MaterialEditor materialEditor,
            Dictionary<string, MaterialProperty> props, float DefaultValue) : base(name, label, materialEditor, props,
            DefaultValue)
        {
        }

        public override void Draw(float space, float BtnSize = 400)
        {
            if (base.props.ContainsKey(base.name))
            {
                MaterialProperty prop = base.props[base.name];
                GUILayout.BeginHorizontal();
                GUILayout.Space(space);
                base.materialEditor.FloatProperty(prop, base.lable.text);
                base.DrawResetBtn(BtnSize, () => { prop.floatValue = this.defaultValue; });
                GUILayout.EndHorizontal();
            }
        }

        protected override float getValue()
        {
            return base.props[base.name].floatValue;
        }

        protected override void ResetDefaultValue()
        {
            base.props[base.name].floatValue = base.defaultValue;
        }

        protected override void setValue(float value)
        {
            base.props[base.name].floatValue = value;
        }
    }
}
#endif